<!doctype html>
<!--
* Tabler - Premium and Open Source dashboard template with responsive and high quality UI.
* @version 1.0.0-beta19
* @link https://tabler.io
* Copyright 2018-2023 The Tabler Authors
* Copyright 2018-2023 codecalm.net Paweł Kuna
* Licensed under MIT (https://github.com/tabler/tabler/blob/master/LICENSE)
-->
<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>Sign in - Tabler - Premium and Open Source dashboard template with responsive and high quality UI.</title>
  <!-- CSS files -->
  <link href="./dist/css/tabler.min.css?1684106062" rel="stylesheet" />
  <link href="./dist/css/tabler-flags.min.css?1684106062" rel="stylesheet" />
  <link href="./dist/css/tabler-payments.min.css?1684106062" rel="stylesheet" />
  <link href="./dist/css/tabler-vendors.min.css?1684106062" rel="stylesheet" />
  <link href="./dist/css/demo.min.css?1684106062" rel="stylesheet" />
  <style>
    @import url('https://rsms.me/inter/inter.css');

    :root {
      --tblr-font-sans-serif: 'Inter Var', -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
    }

    body {
      font-feature-settings: "cv03", "cv04", "cv11";
    }
  </style>
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <script>
    $(document).ready(function () {
      $('#loginForm').submit(function (e) {
        e.preventDefault(); // 阻止表单默认提交行为

        var formData = {
          studentId: $('#studentId').val(),
          password: $('#password').val(),
          code: '', // 这里可能需要添加验证码的获取逻辑
          nickName: ''
        };

        $.ajax({
          type: 'POST',
          url: 'http://localhost:1970/admin/system/user/login', // 这里填写后台登录接口的URL
          contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
          data: $.param(formData), // 将formData转换为URL编码的字符串
          success: function(result) {
                // Handle the successful response
                // Redirect or do something else as needed
                if (result.code === 200) {
                    // If login fails, display the error message to the user
                    console.log('Login successful');
                    alert(result.message);
                    console.log('Login data:', result.data);
                    sessionStorage.setItem('userData', JSON.stringify(result.data));
                    window.location.href = 'index.html'; // Replace '/homepage' with your homepage URL
                } else {
                    // If login is successful, you can redirect or perform other actions
                    alert(result.message);
                }
            },
            error: function(xhr, status, error) {
                // Handle errors
                console.error('Error:', error);
                if (xhr.responseJSON && xhr.responseJSON.message) {
                    // Display the error message to the user
                    alert(xhr.responseJSON.message);
                } else {
                    // If no specific error message is available, display a generic one
                    alert('An error occurred while processing your request. Please try again later.');
            }
          }
        });
      });
    });
  </script>

</head>

<body class=" d-flex flex-column">
  <script src="./dist/js/demo-theme.min.js?1684106062"></script>
  <div class="page page-center">
    <div class="container container-tight py-4">
      <div class="text-center mb-4">
        <a href="." class="navbar-brand navbar-brand-autodark" style="font-size: 25px;">勤工俭学管理系统</a>
      </div>
      <div class="card card-md">
        <div class="card-body">
          <h2 class="h2 text-center mb-4">欢迎登录您的账号</h2>
          <form id="loginForm" autocomplete="off" novalidate>
            <div class="mb-3">
              <label class="form-label">用户名：</label>
              <input type="text" class="form-control" id="studentId" placeholder="your_student_id" autocomplete="off">
            </div>
            <div class="mb-2">
              <label class="form-label">
                密码
                <span class="form-label-description">
                  <a href="./forgot-password.html">我忘记密码了！</a>
                </span>
              </label>
              <div class="input-group input-group-flat">
                <input type="password" class="form-control" id="password" placeholder="Your password"
                  autocomplete="off">
                <span class="input-group-text">
                  <a href="#" class="link-secondary" title="Show password" data-bs-toggle="tooltip">
                    <!-- Download SVG icon from http://tabler-icons.io/i/eye -->
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24"
                      stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
                      <path stroke="none" d="M0 0h24v24H0z" fill="none" />
                      <path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
                      <path d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" />
                    </svg>
                  </a>
                </span>
              </div>
            </div>
            <div class="mb-2">
              <label class="form-check">
                <input type="checkbox" class="form-check-input" />
                <span class="form-check-label">在这个设备上记住我</span>
              </label>
            </div>
            <div class="form-footer">
              <button type="submit" class="btn btn-primary w-100">登录</button></button>
            </div>
          </form>
        </div>

        <div class="hr-text">or</div>
        <div class="text-center text-muted mt-1">
          还没有注册账号？ <a href="./sign-up.html" tabindex="-1">注册</a>
        </div>
        <div class="card-body">
          <div class="row">
            <div class="col"><a href="#" class="btn w-100">
                <!-- Download SVG icon from http://tabler-icons.io/i/brand-github -->
                <svg xmlns="http://www.w3.org/2000/svg" class="icon text-github" width="24" height="24"
                  viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
                  stroke-linejoin="round">
                  <path stroke="none" d="M0 0h24v24H0z" fill="none" />
                  <path
                    d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" />
                </svg>
                登录管理员系统
              </a></div>
            <div class="col"><a href="#" class="btn w-100">
                <!-- Download SVG icon from http://tabler-icons.io/i/brand-twitter -->
                <!-- <svg xmlns="" class="icon text-twitter" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M22 4.01c-1 .49 -1.98 .689 -3 .99c-1.121 -1.265 -2.783 -1.335 -4.38 -.737s-2.643 2.06 -2.62 3.737v1c-3.245 .083 -6.135 -1.395 -8 -4c0 0 -4.182 7.433 4 11c-1.872 1.247 -3.739 2.088 -6 2c3.308 1.803 6.913 2.423 10.034 1.517c3.58 -1.04 6.522 -3.723 7.651 -7.742a13.84 13.84 0 0 0 .497 -3.753c0 -.249 1.51 -2.772 1.818 -4.013z" /></svg> -->
                前往学校官网
              </a></div>
          </div>
        </div>
      </div>

    </div>
  </div>
  <!-- Libs JS -->
  <!-- Tabler Core -->
  <script src="./dist/js/tabler.min.js?1684106062" defer></script>
  <script src="./dist/js/demo.min.js?1684106062" defer></script>
</body>

</html>